#pragma once

#ifdef DLL_FILESOURCEREADER_EXPORTS
#define DLL_FILESOURCEREADER_API __declspec(dllexport)
#pragma comment(user,"dllexport")
#else
#define DLL_FILESOURCEREADER_API __declspec(dllimport)
#pragma comment(user,"dllimport")
#endif

//DLL_FILESOURCEREADER_API PSliceDescription CreateSliceTestDescription();
//DLL_FILESOURCEREADER_API bool OpenSlice(PSliceDescription pSliceDescription);
//DLL_FILESOURCEREADER_API bool GetRow(PSliceDescription pSliceDescription);
//DLL_FILESOURCEREADER_API void CloseSlice(PSliceDescription pSliceDescription);

#ifndef MAX_PATH
#define MAX_PATH 4096
#endif MAX_PATH

typedef struct tagSliceDescription
{
	// in
	wchar_t szFilename[MAX_PATH];
	__int64 iSlice, iSliceCount, iMaxRecordSize;
	char cRowDelimiters[16];

	// from OpenSlice
	HANDLE hFile;
	__int64 iFileSize, iStart, iEnd;
	char *pStart, *pEnd;
	bool bLoaded, bIsFirstSlice, bIsLastSlice, bSkipThisBlock;
	
	// record spec
	bool bSave, bDone;
	char *pCurrentStart, *pCurrentEnded;
} TSliceDescription, *PSliceDescription;

typedef PSliceDescription (*TCreateSliceTestDescription)();
typedef bool (*TOpenSlice)(PSliceDescription pSliceDescription);
typedef bool (*TGetRow)(PSliceDescription pSliceDescription);
typedef void (*TCloseSlice)(PSliceDescription pSliceDescription);

#define GETROW_SEARCH_NOT_FOUND (0)
#define GETROW_SEARCH_FOUND (1)
#define GETROW_END_REACHED (2)

#ifndef malloc
#define malloc(sz) HeapAlloc(GetProcessHeap(), 0, sz)
#endif //malloc

#ifndef free
#define free(p) HeapFree(GetProcessHeap(), 0, p)
#endif //free

